/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import dao.DaoUser;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.User;

/**
 *
 * @author user
 */
public class ControllerLogin {
    
     ConexionDB connn = new ConexionDB();
    Connection conn = connn.establecerConexion();
    
    public boolean Login(String usuario, String clave){
        User us = new User();
        us.setUsuario(usuario);
         User user = new User();
        
        
        DaoUser daouser = new DaoUser();
        // falta agregar conexion para las pruebas...
        try {
            if(daouser.existeUsuario(usuario, conn)){
            user= daouser.load(us, conn);
                    if (user.getClave().equals(clave)){
                        return true;}
            }
            
           /*for(User u: daoUser.findAllUsers()){
              if(u.getUsuario().equals(usuario)&& u.getClave().equals(clave)){
                  return true;
              }*/
              
              
        } catch (SQLException ex) {
           ex.printStackTrace();
        }
        
        //}
        return false;
    }
    
}